package com.quantdo.apex.elasticjob.job;

import com.dangdang.ddframe.job.api.ShardingContext;
import com.quantdo.apex.elasticjob.boot.JobManage;
import com.quantdo.apex.elasticjob.boot.JobStarter;
import com.quantdo.apex.elasticjob.constant.ClearsnapshotBean;
import com.quantdo.apex.elasticjob.service.SnapshotService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author chenkuan
 * @version v1.0
 * @desc 清算核心定时快照任务
 * @date 2019/12/11 011 10:50
 */
@Service
public class SnapshotJob extends JobStarter {

	@Autowired
	private ClearsnapshotBean snapshotBean;

	@Autowired
	private SnapshotService snapshotService;

	@Override
	protected void start(JobManage jobManage) {
		jobManage.addSimpleJob("snapshotJob", snapshotBean.getCron(), 1, null, null, null);
	}

	@Override
	public void handle(ShardingContext context) {
		snapshotService.snapshot(snapshotBean);
	}
}
